package Day2025_04_19;

import java.util.Scanner;

public class Demo01 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        while (t-- != 0) {
            int h = in.nextInt(), a = in.nextInt();
            int H = in.nextInt(), A = in.nextInt();
            int ret = H;
            if (a >= H || A <= 0) {
                System.out.println(-1);
            } else {
                // m : 被毛球怪打死需要多少下
                // n : 打死毛球怪要多少下
                int m = h / A, n = H / a;
                if (h % A != 0) m++;
                if (H % a != 0) n++;
                n--;
                int tmp = m / n;
                if (m % n == 0) tmp--;
                System.out.println(tmp);
            }
        }
    }
}
